/* Layout */
import Layout from '@/layout'

/*
常量路由
需要被静态注册, 不需要进行用户权限的检查
*/
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard'),
        meta: { title: '首页', icon: 'dashboard' }
      }
    ]
  }
]

/*
所有需要权限的异步路由
某个登陆用户可能需要从中过滤出其中一部分动态注册
router.addRoutes(routes)
*/
export const asyncRoutes = [
  /* 权限管理 */
  {
    name: 'Acl',
    path: '/acl',
    component: Layout,
    redirect: '/acl/user/list',
    meta: {
      title: '权限管理',
      icon: 'el-icon-lock'
    },
    children: [
      {
        name: 'User',
        path: 'user/list',
        component: () => import('@/views/acl/user/list'),
        meta: {
          title: '用户管理'
        }
      },
      {
        name: 'Role',
        path: 'role/list',
        component: () => import('@/views/acl/role/list'),
        meta: {
          title: '角色管理'
        }
      },
      {
        name: 'RoleAuth',
        path: 'role/auth/:id',
        component: () => import('@/views/acl/role/roleAuth'),
        meta: {
          activeMenu: '/acl/role/list',
          title: '角色授权'
        },
        hidden: true
      },
      {
        name: 'Permission',
        path: 'permission/list',
        component: () => import('@/views/acl/permission/list'),
        meta: {
          title: '菜单管理'
        }
      }
    ]
  },
  // 商品管理
  {
    name: 'Product',
    // 路由路径
    path: '/product',
    // 路由组件
    component: Layout,
    // 默认重定向地址
    redirect: '/product/trademark/list',
    meta: {
      // 侧边栏的标题 和 网站的标题
      title: '商品管理',
      icon: 'el-icon-lock'
    },
    children: [
      {
        path: 'trademark/list',
        name: 'Trademark',
        component: () => import('@views/product/trademark/list'),
        meta: { title: '品牌管理' }
      },
      {
        path: 'attr/list',
        name: 'Attr',
        component: () => import('@views/product/attr/list'),
        meta: { title: '属性管理' }
      },
      {
        path: 'sku/list',
        name: 'Sku',
        component: () => import('@views/product/sku/list'),
        meta: { title: 'Sku管理' }
      },
      {
        path: 'spu/list',
        name: 'Spu',
        component: () => import('@views/product/spu/list'),
        meta: { title: 'Spu管理' }
      }
    ]
  },
  // 测试
  {
    name: 'Test1215',
    // 路由路径
    path: '/test1215',
    // 路由组件
    component: Layout,
    // 默认重定向地址
    redirect: '/test1215/one/list',
    meta: {
      // 侧边栏的标题 和 网站的标题
      title: '测试1215',
      icon: 'el-icon-lock'
    },
    children: [
      {
        path: 'one/list',
        name: 'One',
        component: () => import('@views/test1215/one/list'),
        meta: { title: '一' }
      },
      {
        path: 'two/list',
        name: 'Two',
        component: () => import('@views/test1215/two/list'),
        meta: { title: '二' }
      },
      {
        path: 'three/list',
        name: 'Three',
        component: () => import('@views/test1215/three/list'),
        meta: { title: '三' }
      }
    ]
  }
]

/*
必须在最后被动态注册
*/
export const anyRoute = { path: '*', redirect: '/404', hidden: true }
